//
//  StateMachine.h
//  MusicAnalyzer
//
//  Created by jiro on 12/04/04.
//  Copyright 2012 jiro music. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#import "State.h"
#import "StateTransitionInfo.h"

@class AppController;

@interface StateMachine : NSObject
{
	NSMutableArray* stateStack;
	
	NSMutableArray* stateTransitInfos;

	AppController* appController;		//	back pointer
}

@property ( assign ) AppController* appController;
@property ( assign ) NSMutableArray* stateStack;

+ (id) sharedStateMachine;

/*	@brief input event, transit state and return command to AppController and AppDocument */
- (Command*) inputKeyEvent: (AppKeyEvent*) e;

/*	@brief input event, transit state and return command to AppController and AppDocument */
- (Command*) inputMouseEvent: (AppMouseEvent*) e;

/*	@brief input event, transit state and return command to AppController and AppDocument */
- (Command*) inputMidiEvent: (AppMidiEvent*) e;

- (void) transit: (StateTransitionInfo*) info;

- (void) pushState: ( State* ) state;

- (void) popState;

-( State* ) currentState;

@end
